package com.qf.team2.netdisc.service.impl;

import com.qf.team2.netdisc.common.pojo.entity.Document;
import com.qf.team2.netdisc.dao.DocumentDeleteMapper;
import com.qf.team2.netdisc.service.DocumentDeleteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DocumentDeleteServiceImpl implements DocumentDeleteService {
    @Autowired
    private DocumentDeleteMapper documentDeleteMapper;
    @Override
    public List<Document> checkUserCapacity(String url, Integer userId) {
        if (url==null){
            throw new RuntimeException("请选择你要删除的文件或者文件夹");
        }
        System.out.println("url:"+url);
        String urls=url.replace("\\","\\\\\\\\");
        List<Document> documents=documentDeleteMapper.DeleteByUrl(urls, userId);
        for (int i=0; i < documents.size(); i++) {
            String replace=documents.get(1).getUrl().replace("\\", "\\\\");
            Integer userId1=documentDeleteMapper.updateByUrl(replace, userId);
        }

        return documents;
    }
}
